//
//  BCProgressHUD.m
//  BCVersion
//
//  Created by 吴 崧 on 14-3-10.
//  Copyright (c) 2014年 Jungle. All rights reserved.
//

#import "BCProgressHUD.h"

@implementation BCProgressHUD

static BCProgressHUD *sharedInstance = nil;





+ (void)showWithTile:(NSString *)title
                       animated:(BOOL)animated {
    
    if (sharedInstance == nil) {
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            sharedInstance = [[super alloc] initWithView:APP_Delegate.window];
        });
    }
    [APP_Delegate.window addSubview:sharedInstance];
    sharedInstance.labelText = title;
	[sharedInstance show:animated];


	
}


+(void)hideWithError:(NSError *)error
            animated:(BOOL)animated
{
    if (error != nil) {
        sharedInstance.labelText = error.message;
    }
    double delayInSeconds = 0.5;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        [self hideAnimated:animated];
    });
}

+(void)hideAnimated:(BOOL)animated
{
    [sharedInstance hide:animated];
}
@end
